package cn.shiwei.basic.controller;

import cn.shiwei.basic.exception.MyException;
import cn.shiwei.basic.util.RequestStatus;
import cn.shiwei.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/verifycode")
public class VerifycodeController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/sendSmsCode")
    private RequestStatus verify(@RequestBody Map<String, String> map){
        try {
            userService.sendMsg(map);
            return RequestStatus.me();
        } catch (MyException e) {
            System.out.println("捕获自定义异常");
            e.printStackTrace();
            return RequestStatus.me().setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return RequestStatus.me().setMessage(e.getMessage());
        }
    }

}
